#ifndef __CONTROL_H_
#define __CONTROL_H_

#include "stm32f10x.h"                  // Device header

#define LED_1_Set() GPIO_WriteBit(GPIOC,GPIO_Pin_13,Bit_RESET)
#define LED_1_Clr() GPIO_WriteBit(GPIOC,GPIO_Pin_13,Bit_SET)
#define LED_2_Set() GPIO_WriteBit(GPIOC,GPIO_Pin_14,Bit_RESET)
#define LED_2_Clr() GPIO_WriteBit(GPIOC,GPIO_Pin_14,Bit_SET)
#define LED_3_Set() GPIO_WriteBit(GPIOC,GPIO_Pin_15,Bit_RESET)
#define LED_3_Clr() GPIO_WriteBit(GPIOC,GPIO_Pin_15,Bit_SET)

#define Buzzer_Set() GPIO_WriteBit(GPIOB,GPIO_Pin_9,Bit_SET)
#define Buzzer_Clr() GPIO_WriteBit(GPIOB,GPIO_Pin_9,Bit_RESET)

#define Lock_Set() GPIO_WriteBit(GPIOC,GPIO_Pin_0,Bit_SET)
#define Lock_Clr() GPIO_WriteBit(GPIOC,GPIO_Pin_0,Bit_RESET)

#define Fan_Set() GPIO_WriteBit(GPIOC,GPIO_Pin_6,Bit_SET)
#define Fan_Clr() GPIO_WriteBit(GPIOC,GPIO_Pin_6,Bit_RESET)

static void Led_Init(void);
static void Set_Led(uint8_t led_num,uint8_t level);

static void Buzzer_Init(void);
static void Set_Buzzer(uint8_t level);

static void Fan_Init(void);

static void Lock_Init(void);
static void Set_Lock(uint8_t level);

static void Pwm_Led_Init(void);
static void Pwm_Led_SetCompare(uint16_t Compare);

static void Fan_TIM8_PWM_Init(uint16_t arr,uint16_t psc);
static void Fan_Set_PWM(uint8_t value_Per);
void Motor_Init(void);
void Motor_SetSpeed(int8_t Speed);

typedef struct{
	void (*Led_Init)(void);
	void (*Set_Led)(uint8_t led_num,uint8_t level);

	void (*Buzzer_Init)(void);
	void (*Set_Buzzer)(uint8_t level);
	
	void (*Fan_Init)(void);
	
	void (*Lock_Init)(void);
	void (*Set_Lock)(uint8_t level);
	
	void (*Pwm_Led_Init)(void);
	void (*Pwm_Led_SetCompare)(uint16_t Compare);
	
	void (*Fan_TIM8_PWM_Init)(uint16_t arr,uint16_t psc);
	void (*Fan_Set_PWM)(uint8_t value_Per);
	
}Ctrl_t;

extern Ctrl_t Ctrl;

#endif

